<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>购物车</title>
</head>
<body>
    <a href="/home/" class="button">返回</a>
    <h2>购物车</h2>
    {% if messages %}
    <ul class="messages">
        {% for message in messages %}
        <li {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}</li>
        {% endfor %}
    </ul>
    {% endif %}

    <form action="/cart/" method="post">
        {% csrf_token %}
        <button type="submit" name="action" value="1">添加商品</button>
        <button type="submit" name="action" value="2">移除商品</button>
        <button type="submit" name="action" value="4">查询购物车商品信息</button>
        <button type="submit" name="action" value="5">创建订单</button>
        <button type="submit" name="action" value="6">查询所有信息</button>
        <div class="container mt-5">
            <h1>输入商品名称进行对应操作</h1>
            <div class="mb-3">
                <label for="id_product" class="form-label">商品id</label>
                {{ form.productid.errors }}
                {{ form.productid }}
            </div>
        </div>
    </form>
    {% if returnall %}
        <ul>
            <p><strong>商品种类数:</strong> {{ returnall.itemcount }}</p>
            <p><strong>总价:</strong> {{ returnall.total_amount }}</p>
            <p><strong>优惠后价格:</strong> {{ returnall.actual_payment }}</p>
        </ul>
    {% endif %}
    {% if products %}
    <ul>
        {% for product in products %}
        <li>
            <p><strong>商品ID:</strong> {{ product.productid }}</p>
            <p><strong>商品数量:</strong> {{ product.count }}</p>
            <p><strong>商品单价:</strong> {{ product.price }}</p>
        </li>
        {% endfor %}
    </ul>
    {% else %}
    <p>商品不存在。</p>
    {% endif %}

</body>
</html>